<script>
import store from '@/store'
import { appUpgrade, mpUpgrade } from '@/utils/upgrade'

export default {
  /**
   * @name nvue 界面全局数据，非nvue 使用 this
   */
  globalData: {
    $t: null,
    $i18n: null,
    $utils: null,
    $config: null,
    $api: null,
  },
  onLaunch: function () {
    // App版本更新
    appUpgrade()
    // 系统信息
    store.commit('SET_SYSTEM_INFO')
    // 预加载
    // this.handlePreLoadPages()
    // Init global data
    this.onInitGlobalData()
  },
  onShow: function () {
    // 微信小程序版本更新
    mpUpgrade()
  },
  methods: {
    // 预加载
    handlePreLoadPages() {
      const tabBarPages = [
        // '/pages/index/index',
        '/pages/mine/mine',
      ]
      this.$nextTick(() => {
        for (const item of tabBarPages) {
          uni.preloadPage({ url: item })
        }
      })
    },
    // 为Nvue初始化 GlobalData
    onInitGlobalData() {
      this.globalData.$t = (k) => this.$t(k)
      this.globalData.$i18n = this.$i18n
      this.globalData.$utils = this.$utils
      this.globalData.$config = this.$config
      this.globalData.$api = this.$api
    },
  },
}
</script>

<style lang="scss">
@import '@/uni_modules/uview-ui/index.scss';
@import '@/style/index.scss';

::v-deep {
  .u-status-bar {
    background: $com-color-content-bg !important;
  }

  // 主题切换导航栏样式覆盖
  .u-navbar__content {
    background-color: $com-color-content-bg !important;

    .u-title,
    .u-navbar__content__left .u-icon__icon {
      color: $com-color-main !important;
    }
  }

  // input字体统一
  uni-input,
  .uni-input-placeholder,
  uni-textarea,
  .uni-textarea-placeholder {
    color: $com-color-main !important;
    font-size: $com-text-md !important;
  }

  // input字体统一
  .uni-input-placeholder,
  .uni-textarea-placeholder {
    color: $com-color-tips !important;
    font-size: $com-text-md !important;
  }
}
</style>
